package com.lsq.tucao.user.controller;

import com.lsq.tucao.user.response.JsonResult;
import com.lsq.tucao.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class LoginAndLogoutController {

    @Autowired
    private UserService userService;

    /**
     * @author lsq
     * @description 登录
     * @param username 用户名
     * @param password 密码
     * @return com.lsq.tucao.login.response.JsonResult
     * @create 2021/4/11 21:50
     */
    @PostMapping("/login")
    public JsonResult login(@RequestParam("username") String username, @RequestParam("password") String password) {
        log.debug("username:{}" + username);
        log.debug("password:{}" + password);

        return userService.login(username,password);
    }

    /**
     * 退出登录逻辑处理
     */
    @PostMapping("/logout")
    public JsonResult logout(@RequestParam("username") String username) {
        log.debug("username:{}" + username);
        return userService.logout(username);
    }


}
